package org.vacoor.xqq.hotkey;

import javax.swing.event.EventListenerList;

/**
 * User: Vacoor
 */
public abstract class AbstractOSHotKeyBinder implements OSHotKeyBinder {
    protected EventListenerList listeners = new EventListenerList();
    protected final int identifier;
    protected int modifier;
    protected int key;

    public AbstractOSHotKeyBinder(int identifier) {
        this.identifier = identifier;
    }

    @Override
    public int getIdentifier() {
        return identifier;
    }

    @Override
    public int getMidifier() {
        return modifier;
    }

    @Override
    public int getKey() {
        return key;
    }

    @Override
    public void setHotKey(int midifier, int key) throws OSHotKeyConflictException {
        this.modifier = midifier;
        this.key = key;
    }

    @Override
    public void addOSHotKeyListener(OSHotKeyListener listener) {
        listeners.add(OSHotKeyListener.class, listener);
    }

    @Override
    public void removeOSHotKeyListener(OSHotKeyListener listener) {
        listeners.remove(OSHotKeyListener.class, listener);
    }

    @Override
    public OSHotKeyListener[] getOSHotKeyListeners() {
        return listeners.getListeners(OSHotKeyListener.class);
    }
}
